<template>
	<view>
		<a-tree v-model="list" @click="treeClick" @change="treeChange"/>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [{
					lable: "23432421",
					child: [{
						lable: "998777"
					}, {
						lable: "5435435",
						child: [{
							lable: "23432421",
							child: [{
								lable: "998777"
							}, {
								lable: "5435435"
							}]
						}]
					}]
				}, {
					lable: "23432421",
					child: [{
						lable: "998777"
					}, {
						lable: "5435435",
						child: [{
							lable: "23432421",
							child: [{
								lable: "998777"
							}, {
								lable: "5435435"
							}]
						}]
					}]
				}]
			}
		},
		methods: {
			treeClick(e) {
				console.log(e);
			},
			treeChange(e){
				console.log(e);
			},
			async get(parm) {
				const data = new Array(10).fill({
					lable: "23432421",
					child: [{
						lable: "998777"
					}, {
						lable: "5435435",
						child: [{
							lable: "23432421",
							child: [{
								lable: "998777"
							}, {
								lable: "5435435"
							}]
						}]
					}]
				});
				console.log('请求：' + JSON.stringify({
					...parm
				}));
				return new Promise(r => {
					setTimeout(e => {
						r({
							total: 0,
							data: [{
								lable: "23432421",
								child: [{
									lable: "998777"
								}, {
									lable: "5435435",
									child: [{
										lable: "23432421",
										child: [{
											lable: "998777"
										}, {
											lable: "5435435"
										}]
									}]
								}]
							}, {
								lable: "23432421",
								child: [{
									lable: "998777"
								}, {
									lable: "5435435",
									child: [{
										lable: "23432421",
										child: [{
											lable: "998777"
										}, {
											lable: "5435435"
										}]
									}]
								}]
							}]
						})
					}, 1000);
				});

				return this.$http.get('/api/v1/bMessage/selectBMessagesByMsgTypeCode', {
					...parm
				}).then((result) => {
					return {
						total: result.totalSize,
						data: result.results.map(x => {
							return {
								...x,
								extra: '发布人:' + x.senderName,
								date: format(x.sendTime)
							}
						})
					}
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	page {
		height: 100%;
	}
</style>
